package com.example.smart.room.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.smart.room.bean.AnimalBean
import com.example.smart.room.constants.SqlConstant

@Dao
interface AnimalDAO {

    @Insert
    suspend fun insert(bean: AnimalBean)

    @Query("select * from ${SqlConstant.ANIMAL} order by id asc")
    suspend fun getAllData(): MutableList<AnimalBean>

    @Query("select * from ${SqlConstant.ANIMAL} where id =:id")
    suspend fun getData(id: Long): AnimalBean?

    @Update
    suspend fun update(data: AnimalBean)

    @Query("delete from ${SqlConstant.ANIMAL} where id =:id")
    suspend fun delete(id: Long)
}